<template>
	<view class="content">
		<view class="nav-box flexWrap">
			<view class="nav-item flexWarpCenterColumn" v-for="(item,index) in navList" :key="index" :class="{active:currmentIndex==index}" @tap="changeNav(index)">
				<text>{{item.name}}</text>
				<text class="line"></text>
			</view>
		</view>
		<view class="shop-box" v-for="item in 5" @tap="goPage('/pages/shop/shopOrderDetails')">
			<view class="top-box flexWrap">
				<view class="date">2017-06-24</view>
				<view class="status">已发货</view>
			</view>
			<view class="shop-cont flexWrapNo">
				<image src="https://static.mo-yu.vip/uploads/20230710/6503c13d70f87c00601fa6eeb42034f2.jpeg" class="shop-img"></image>
				<view class="shop-info-box flexWarpColumn">
					<view class="info-box">
						<view>貘鱼定制 - 黑鲨大头杆</view>
						<view class="specs-box">当日到店 , x2</view>
					</view>
					<view class="price">¥ 45.00</view>
				</view>
			</view>
			<view class="total-box">
				共2件 总额 <text class="price">¥ 45.00</text>
			</view>
		</view>
		<uni-load-more v-if="showLoadStatus" :status="status" :size="14" :content-text="contentText" />
		<view class="empty-box" v-if="showEmpty">
			<image src="https://static.mo-yu.vip/wechat/images/orderEmpty.png"></image>
		</view>
	</view>
</template>

<script>
	import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue'
	export default {
		components: {
			uniLoadMore
		},
		data() {
			return {
				navList:[
					{
						name:"全部"
					},
					{
						name:"待付款"
					},
					{
						name:"待发货"
					},
					{
						name:"已收货"
					}
				],
				currmentIndex:0,
				//下拉刷新
				page: 1,
				size:10,
				showEmpty: true,
				showLoadStatus: false,
				more: true,
				contentText: {
					contentdown: '上拉加载更多~',
					contentrefresh: '加载中...',
					contentnomore: '已经到底了~~'
				},
				status: 'loading',
				orderList:[],
			};
		},
		onLoad() {
			this.getData();
		},
		methods:{
			changeNav(index){
				this.currmentIndex=index
			},
			getData(){
				let self=this
				this.$request.post(this.$api.shopOrderList, {
					page:this.page++,
					num:this.size,
				}, {
					token:true
				}).then(res => {
					if (res.code == 1) {
						let {
							data = {}
						} = res;
						let newArray =data.list
						this.count=data.count
						for (let i in newArray) {
							newArray[i].createtime = this.$tools.formatDate(newArray[i].createtime)
						}
						if (newArray.length == 0 && self.page == 2) {
							self.showEmpty = true
							self.showLoadStatus = false
							self.more = false // 不能再次请求了
							return false;
						} else {
							self.showLoadStatus = true
							self.more = true
							self.showEmpty = false
							self.status = 'loading'
						}
						if (newArray.length < this.size) { // 说明没有更多数据
							self.status = 'noMore'
							self.more = false
							self.showEmpty = false
						}
						self.orderList=self.orderList.concat(newArray);
					}
				}).finally(() => {
					setTimeout(()=>{
						this.$tools.hideLoading()
					}, 1000)
				})
			},
		}
	}
</script>

<style lang="scss">
	.content{
		padding: 32upx;
	}
	.nav-box{
		border-bottom: 1rpx solid #36355E;
		padding-bottom: 30upx;
		.nav-item{
			font-size: 32rpx;
			font-family: PingFang SC-Medium, PingFang SC;
			font-weight: 500;
			color: #82819B;
			.line{
				display: inline-block;
				width: 94rpx;
				height: 4rpx;
				margin-top: 10rpx;
			}
		}
		.active{
			color: #fff;
			.line{
				background: #26BCFD;
			}
		}
	}
	.shop-box{
		height: 480rpx;
		background: #1D1C5C;
		border-radius: 16rpx;
		margin-top: 36upx;
		.top-box{
			font-size: 28rpx;
			font-family: PingFang SC, PingFang SC;
			font-weight: 400;
			color: #FFFFFF;
			padding: 32upx 28upx;
		}
		.shop-cont{
			padding: 32upx 28upx;
			border-top: 1rpx solid #36355E;
			border-bottom: 1rpx solid #36355E;
			.shop-img{
				width: 224rpx;
				height: 224rpx;
				border-radius: 16rpx 16rpx 16rpx 16rpx;
			}
			.shop-info-box{
				margin-left: 28upx;
				font-size: 28rpx;
				font-family: PingFang SC, PingFang SC;
				font-weight: 400;
				color:#FFFFFF;
				height: 224rpx;
				justify-content: space-between;
				.info-box{
					.specs-box{
						color: #8786A8;
						margin-top: 12upx;
					}
				}
			}
		}
		.total-box{
			font-size: 28rpx;
			font-family: PingFang SC, PingFang SC;
			font-weight: 400;
			color:#8786A8;
			line-height: 100upx;
			text-align: right;
			padding: 0 28upx;
			.price{
				color: #FFFFFF;
				margin-left: 24upx;
			}
		}
	}
</style>
